package application;

import javafx.application.Preloader;
import javafx.application.Preloader.StateChangeNotification.Type;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class MyApplication extends Preloader {

	private Stage preloaderStage;

	@Override
	public void start(Stage primaryStage) throws Exception {
		this.preloaderStage = primaryStage;
		VBox vBox = FXMLLoader.load(MyPreloaderEvent.class.getResource("MyPreloader.fxml"));
		BorderPane root = new BorderPane(vBox);
		Scene scene = new Scene(root);
		primaryStage.setWidth(400);
		primaryStage.initStyle(StageStyle.UNDECORATED);
		primaryStage.setHeight(300);
		primaryStage.setScene(scene);
		primaryStage.show();
		
	}

	@Override
	public void handleStateChangeNotification(StateChangeNotification stateChangeNotification) {
		if (stateChangeNotification.getType() == Type.BEFORE_START) {
			preloaderStage.hide();
		}
	}

}
